package com.yonyou.brigade.third_parties.zteitc.model;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.yonyou.ybzboot.starter.common.util.StringUtil;
import com.yonyou.ybzboot.uc.dto.UcUserDto;

import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author houyb@yonyou.com
 * @since 2018-12-24
 */
@TableName("zte_user")
public class ZteUser extends Model<ZteUser> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 员工编码
     */
    @TableField("employee_number")
    private String employeeNumber;
    /**
     * 员工姓名(中)
     */
    @TableField("employee_name")
    private String employeeName;
    /**
     * 手机号码
     */
    @TableField("mobile_phone")
    private String mobilePhone;
    /**
     * 电子邮件
     */
    @TableField("email")
    private String email;
    /**
     * 是否启用0,1
     */
    @TableField("enabled_flag")
    private String enabledFlag;
    /**
     * 证件编号
     */
    @TableField("card_type")
    private String cardType;
    /**
     * 证件姓名
     */
    @TableField("owner_name")
    private String ownerName;
    /**
     * 证件编码
     */
    @TableField("card_num")
    private String cardNum;

    @TableField("dept_code")
    private String deptCode;



    /*
            部门名称
         */
    @TableField(exist = false)
    private String deptName;

    /**
     * 职务
     */
    @TableField("user_property1")
    private String userProperty1;

    /**
     * 租户id
     */
    @TableField("tenant")
    private String tenant;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getEmployeeNumber() {
        return employeeNumber;
    }

    public void setEmployeeNumber(String employeeNumber) {
        this.employeeNumber = employeeNumber;
    }

    public String getEmployeeName() {
        return employeeName;
    }

    public void setEmployeeName(String employeeName) {
        this.employeeName = employeeName;
    }

    public String getMobilePhone() {
        return mobilePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEnabledFlag() {
        return enabledFlag;
    }

    public void setEnabledFlag(String enabledFlag) {
        this.enabledFlag = enabledFlag;
    }

    public String getCardType() {
        return cardType;
    }

    public void setCardType(String cardType) {
        this.cardType = cardType;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public String getCardNum() {
        return cardNum;
    }

    public void setCardNum(String cardNum) {
        this.cardNum = cardNum;
    }

    public String getDeptCode() {
        return deptCode;
    }

    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }

    public String getUserProperty1() {
        return userProperty1;
    }

    public void setUserProperty1(String userProperty1) {
        this.userProperty1 = userProperty1;
    }

    public String getTenant() {
        return tenant;
    }

    public void setTenant(String tenant) {
        this.tenant = tenant;
    }

    public String getDeptName() { return deptName; }

    public void setDeptName(String deptName) { this.deptName = deptName; }

    public static final String ID = "id";

    public static final String EMPLOYEENUMBER = "employeeNumber";

    public static final String EMPLOYEENAME = "employeeName";

    public static final String MOBILEPHONE = "mobilePhone";

    public static final String EMAIL = "email";

    public static final String ENABLEDFLAG = "enabledFlag";

    public static final String CARDTYPE = "cardType";

    public static final String OWNERNAME = "ownerName";

    public static final String CARDNUM = "cardNum";

    public static final String DEPTCODE = "deptCode";

    public static final String USERPROPERTY1 = "userProperty1";

    public static final String TENANT = "tenant";

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "ZteUser{" +
        "id=" + id +
        ", employeeNumber=" + employeeNumber +
        ", employeeName=" + employeeName +
        ", mobilePhone=" + mobilePhone +
        ", email=" + email +
        ", enabledFlag=" + enabledFlag +
        ", cardType=" + cardType +
        ", ownerName=" + ownerName +
        ", cardNum=" + cardNum +
        ", deptCode=" + deptCode +
        ", userProperty1=" + userProperty1 +
        "}";
    }

    public boolean toCompareUcUserDto(UcUserDto ucUserDto)
    {
        boolean equal=true;
        if(StringUtil.isEmpty(employeeNumber)){
            if(!StringUtil.isEmpty(ucUserDto.getPersonCode()))
            {
                return false;
            }
        }
        else
        {
            if(!employeeNumber.equals(ucUserDto.getPersonCode()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(employeeName)){
            if(!StringUtil.isEmpty(ucUserDto.getUserName()))
            {
                return false;
            }
        }
        else
        {
            if(!employeeName.equals(ucUserDto.getUserName()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(enabledFlag)){
            return false;
        }
        else
        {
            if(enabledFlag.equals("Y") && ucUserDto.getValid() != 1){
                return false;
            }
            if(enabledFlag.equals("N") && ucUserDto.getValid() != 0){
                return false;
            }
        }

        if(StringUtil.isEmpty(email)){
            if(!StringUtil.isEmpty(ucUserDto.getEmail()))
            {
                return false;
            }
        }
        else
        {
            if(!email.equals(ucUserDto.getEmail()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(mobilePhone)){
            if(!StringUtil.isEmpty(ucUserDto.getPhone()))
            {
                return false;
            }
        }
        else
        {
            if(!mobilePhone.equals(ucUserDto.getPhone()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(cardType)){
            return false;
        }
        else
        {
            if(!cardType.equals("0"))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(ownerName)){
            if(!StringUtil.isEmpty(ucUserDto.getUserName()))
            {
                return false;
            }
        }
        else
        {
            if(!ownerName.equals(ucUserDto.getUserName()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(cardNum)){
            if(!StringUtil.isEmpty(ucUserDto.getPassengerId()))
            {
                return false;
            }
        }
        else
        {
            if(!cardNum.equals(ucUserDto.getPassengerId()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(deptCode)){
            if(!StringUtil.isEmpty(ucUserDto.getDeptCode()))
            {
                return false;
            }
        }
        else
        {
            if(!deptCode.equals(ucUserDto.getDeptCode()))
            {
                return false;
            }

        }

        if(StringUtil.isEmpty(userProperty1)){
            if(!StringUtil.isEmpty(ucUserDto.getPostName()))
            {
                return false;
            }
        }
        else
        {
            if(!userProperty1.equals(ucUserDto.getPostName()))
            {
                return false;
            }

        }

        return  equal;
    }
}
